// /////////////////////////////////////////////////////////////////////////////
//
// Name:            TextBillboardComponent.h
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Declaration of the TextBillboardComponent class.
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

#ifndef __TEXTBILLBOARDCOMPONENT_H__
#define __TEXTBILLBOARDCOMPONENT_H__

// Include files
#include "../../dependencies.h"
#include "BillboardComponent.h"


// TextBillboardComponent class
//! Component wrapper of Irrlicht's IBillboardTextSceneNode.
//!
//! <b>XML:</b>
//! \code
//! <TextBillboardComponent>
//!    <!-- Properties -->
//! </TextBillboardComponent>
//! \endcode
class TextBillboardComponent : public BillboardComponent
{
public:

    // Initialisation and deinitialisation
    //! Constructor (default)
    TextBillboardComponent(Entity *parent);
    //! Constructor
    //! @param parent        The parent entity to which the component should be added.
    //! @param fontFileName  Filename of the font to load.
    //! @param text          The text to display on the billboard.
    //! @param size          The billboard's width and height.
    //! @param colorTop      The color of the vertices at the top of the billboard.
    //! @param colorBottom   The color of the vertices at the bottom of the billboard.
    //! @note Not available in AngelScript.
    TextBillboardComponent(Entity *parent, const std::string &fontFileName, const wchar_t *text,
                           const dimension2df &size = dimension2df(10.0f, 10.0f),
                           const SColor &colorTop = SColor(255, 255, 255, 255),
                           const SColor &colorBottom = SColor(255, 255, 255, 255));
    //! Constructor
    //! @param parent        The parent entity to which the component should be added.
    //! @param fontFileName  Filename of the font to load.
    //! @param text          The text to display on the billboard.
    //! @param size          The billboard's width and height.
    //! @param colorTop      The color of the vertices at the top of the billboard.
    //! @param colorBottom   The color of the vertices at the bottom of the billboard.
    TextBillboardComponent(Entity *parent, const std::string &fontFileName, const std::string &text,
                           const dimension2df &size = dimension2df(10.0f, 10.0f),
                           const SColor &colorTop = SColor(255, 255, 255, 255),
                           const SColor &colorBottom = SColor(255, 255, 255, 255));
    //! Deconstructor
    ~TextBillboardComponent();

    // Methods
    //! Returns a direct pointer to the IBillboardTextSceneNode.
    //! @note Not available in AngelScript.
    IBillboardTextSceneNode* getBillboardTextSceneNode();

    //! Sets the text string.
    //!
    //! <b>XML:</b>
    //! \code
    //! <text type="string" value="" />
    //! \endcode
    //!
    //! @param text          Text to set.
    void setText(const std::string &text);
    //! Sets the text string.
    //! @param text          Text to set.
    //! @note Not available in AngelScript.
    void setText(const wchar_t *text);
    //! Sets the color of the text.
    //!
    //! <b>XML:</b>
    //! \code
    //! <textColor type="color" value="" />
    //! \endcode
    //!
    //! @param color         New color of the text.
    void setTextColor(const SColor &color);

    // Serialization
    //! Serializes this object.
    //! @param attributes
    virtual bool onSerialization(SerializedAttributes *attributes);
    //! Deserializes this object.
    //! @param attributes
    virtual bool onDeserialization(SerializedAttributes *attributes);

private:

    // Private methods
    void init(IGUIFont *font, const wchar_t *text, const dimension2df &size, const SColor &colorTop,
              const SColor &colorBottom);

    // Members
    IBillboardTextSceneNode *mBillboardTextSN;

    stringw mText;
    SColor mTextColor;
};

#endif
